#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

char buf[1<<20];
int TC;

int N;
int W;
int L[5005];
int R[5005];
int D[5005];

int main() {
#define SUBMIT 0
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif

	gets(buf); TC = atoi(buf);
	
	while (TC--) {
		scanf("%d%d",&W,&N);
		for (int i = 0; i < N; ++i)
			scanf("%d%d%d",&D[i],&L[i],&R[i]);
		double l = 0, r = W;
		bool ok = 1;
		for (int i = 0; i < N; ++i) {
			for (int j = i+1; j < N; ++j) {
				double cl = 0 ,cr = 0;
				if (L[i] == R[j])
					cl = L[i];
				else
				{
					double a = 1.0*(D[i]-D[j])/(L[i]-R[j]);
					double b = D[i]-a*L[i];
					cl = -b/a;
				}
				if (R[i] == L[j])
					cr = R[i];
				else {
					double a = 1.0*(D[i]-D[j])/(R[i]-L[j]);
					double b = D[i]-a*R[i];
					cr = -b/a;					
				}
				if (cl > cr) 
					swap(cl,cr);
				l = max(l,cl);
				r = min(r,cr);
				if (l > r)
				{
					ok = 0;
					goto out;
				}
			}
		}
		out:;
		
		if (ok)
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}





